// pages/page/return_good/fill_express/fill_express.js
var request_api = require('../../../../utils/require_api.js')
import Dialog from '../../../../youzan/youzan_dist/dialog/dialog';
import Toast from '../../../../youzan/youzan_dist/toast/toast';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    show: false,
    express:[{name:'圆通'},{name:'申通'},{name:'中通'},{name:'韵达'},{name:'百世汇通'},{name:'天天快递'},{name:'顺丰'}],
    express_company:'',
    express_no:'',
    returnid:'',
    expressid:'',
    returnid:'',
  },
  //隐藏申请原因
  hideModal(e) {
    this.data.express_company = e.currentTarget.dataset.selectseason.name;
    this.setData({
      modalName: null,
      express_company: e.currentTarget.dataset.selectseason.name
    })
  },
  onClickIcon(e){
    console.log(e);
  },
  //显示申请原因
  showModal(e) {
    this.setData({
      modalName: 'DrawerModalL'
    })
  },

  getInput(e){
    this.data.expressid = e.detail.value;
  },

  comfirm(){
    console.log(this.data.express_company);
    let shortname='';
    if (this.data.express_company=='中通'){
      shortname='zhongtong';
    } else if (this.data.express_company == '圆通'){
      shortname = 'yuantong';
    } else if (this.data.express_company == '申通') {
      shortname = 'shentong';
    }
    else if (this.data.express_company == '韵达') {
      shortname = 'yunda';
    }
    else if (this.data.express_company == '百世汇通') {
      shortname = 'baishihuitong';
    }
    else if (this.data.express_company == '顺丰') {
      shortname = 'shunfeng';
    }
    else if (this.data.express_company == '天天快递') {
      shortname = 'tiantiankuaidi';
    }


    request_api.request(
      'updatereturntype', //需要传给wxrequest.js 的 url
      {
        return_id: this.data.returnid,
        logistics_code: this.data.expressid,
        express_company: this.data.express_company,
        short_express_company: shortname,
        return_type: '已发货，申请退货',
      }, //需要传的 data
      function (res) {
        Toast.loading({
          mask: true,
          duration: 2000, // 持续展示 toast
          forbidClick: true, //禁用背景点击
          message: '提交中......',
          loadingType: 'spinner',
        });
        setTimeout(function () {
          Toast('请你耐心等候，等待管理员收货完成退款哦~~~');
        }, 2000);
        setTimeout(function () {
          wx.navigateBack({
            url: '../return_good',
          });
        }, 3000);
      },
      function () {
        console.log("錯誤");
      },
    )



  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      console.log(options,"www");
      this.data.returnid=options.returnid;
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})